package com.forgenet.login.config;

import com.sparrow.common.EnableSparrowCommon;
import com.sparrow.common.util.PropertiesUtil;
import com.sparrow.common.uuid.TimeUUIDGenerator;
import com.sparrow.mongo.EnableSparrowMongo;
import com.sparrow.redis.EnableSparrowRedis;
import com.sparrow.servicemgr.consul.ConsulManager;
import com.sparrow.socket.http.EnableSparrowHttp;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableSparrowCommon
@EnableSparrowHttp
@EnableSparrowMongo
@EnableSparrowRedis
@ComponentScan({
        "com.forgenet.login"
})
public class LoginConfig {
    @Bean
    public ConsulManager consulManager() {
        ConsulManager consulManager = new ConsulManager();
        consulManager.register(PropertiesUtil.getProperty("node.group"), PropertiesUtil.getProperty("node.id"),
                PropertiesUtil.getProperty("node.ip"), PropertiesUtil.getPropertyAsInt("node.port"));
        return consulManager;
    }

    @Bean
    public TimeUUIDGenerator idGenerator() {
        return new TimeUUIDGenerator(1);
    }

}
